import Vue from 'vue';
import VueRouter from 'vue-router';
import PageLayout from '@/layouts/PageLayout.vue';
import UserLayout from '@/layouts/UserLayout.vue';
Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err);
};
export const routes = [
  {
    path: '/',
    name: 'pages',
    redirect: '/home',
    component: PageLayout,
    children: [
      {
        path: '/home',
        name: 'HomePage',
        meta: {
          title: 'home'
        },
        component: () => import('@/views/Home/Home.vue')
      },
      {
        path: '/demos/demo1',
        name: 'Demo1',
        meta: {
          title: 'Demo1'
        },
        component: () => import('@/views/demos/demo1.vue')
      }
    ]
  }
  // {
  //   path: '/users',
  //   name: 'user',
  //   redirect: '/login',
  //   component: UserLayout,
  //   children: [
  //     {
  //       path: '/login',
  //       name: 'Login',
  //       component: () => import('@/views/User/Login.vue')
  //     }
  //   ]
  // }
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
});

export default router;
